package com.syg.case04;

import org.springframework.aop.support.AopUtils;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestMethod;
import org.springframework.web.bind.annotation.RestController;

import javax.annotation.Resource;

@RestController
public class ControllerCase04 {

    @Resource
    ACase04 acase04;

    /**
     * 情况4：B类被AOP增强，在B类中的方法1中调用方法2,方法2不会被拦截
     * 方法2不会被拦截,AOP执行1次
     */
    @RequestMapping(value = "/case04",method = RequestMethod.GET)
    public void proxyClassTest(){
        // aopProxy1结果是true 此时是通过AOP增强的对象,因为切入点配置到了类
        boolean aopProxy1 = AopUtils.isAopProxy(acase04);
        System.out.println("proxyClassTest result = " + aopProxy1);
        System.out.println("spring ioc=" + acase04.hashCode() + ",地址值=" + acase04+ ",内存地址," + System.identityHashCode(acase04));
        acase04.save01(acase04);
    }
}
